package yto.freemarker.springaop.processor;

import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

/**
 * 扫描，是否自动装配bean
 *
 * @author dongxing
 **/
public class YtoBeanScanner implements ImportBeanDefinitionRegistrar {

    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
        BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(AopProcessor.class);
        AbstractBeanDefinition definition = beanDefinitionBuilder.getBeanDefinition();
        definition.setBeanClass(AopProcessor.class);
        registry.registerBeanDefinition("aopProcessor",definition);

    }
}
